package com.breezelin.freshmarket.entities.req;

/**
 * Created by Breeze Lin
 * 2016/9/26 10:49
 * breezesummerlin@163.com
 */

import com.breezelin.freshmarket.entities.JsonStruct;
import com.breezelin.freshmarket.utils.SignUtil;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * 用户登录请求信息体
 */
public class LoginInfo implements JsonStruct {

	/*
	"Body": {
        "AdChannelName": "",
        "UserName": "egsmPxTmb2y+wej0eOiStw==",
        "Password": "E4+bYSFUcYt4dKgfbpHzMg=="
    }
	 */

	/**
	 * 用户名
	 */
	private String userName;
	/**
	 * 密码
	 */
	private String password;
	/**
	 * todo 未知字段
	 */
	private String adChannelName;

	/**
	 * 登录请求体
	 *
	 * @param userName 用户名
	 * @param password 密码
	 */
	public LoginInfo(String userName, String password) {
		this.userName = userName;
		this.password = password;
		adChannelName = "";
	}

	@Override
	public void fromJson(JSONObject jsonObject) {
	}

	@Override
	public JSONObject toJson() {
		JSONObject ret = new JSONObject();
		try {
			ret.put("AdChannelName", adChannelName);
			ret.put("UserName", SignUtil.encrypt(userName));
			ret.put("Password", SignUtil.encrypt(password));
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return ret;
	}
}
